<?php

require_once ('Interface.php');
require_once ('configs/Config.php');
class Exception_Handler_Standard implements Exceptions_Handler_Interface {
	
	public function handleError($error, $exception) {
		$exceptionType = get_class ( $exception );
		$error->exception = $exception;
		switch ($exceptionType) {
			case 'Zend_Controller_Router_Exception' :
				if (404 == $exception->getCode ()) {
					$error->type = Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE;
				} else {
					$error->type = Zend_Controller_Plugin_ErrorHandler::EXCEPTION_OTHER;
				}
				break;
			case 'Zend_Controller_Dispatcher_Exception' :
				$error->type = Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER;
				break;
			case 'Zend_Controller_Action_Exception' :
				if (404 == $exception->getCode ()) {
					$error->type = Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION;
				} else {
					$error->type = Zend_Controller_Plugin_ErrorHandler::EXCEPTION_OTHER;
				}
				break;
			case 'PermissionDeniedException' :
				$error->type = ExceptionConfig::PERM_EXCEPTION;
				break;
			case 'UnderMaintenanceException' :
				$error->type = ExceptionConfig::UNDERMAINTENANCE_EXCEPTION;
				break;
			default :
				$error->type = Zend_Controller_Plugin_ErrorHandler::EXCEPTION_OTHER;
				break;
		}
		return $error;
	}
}

?>